﻿@using SCMS.Resource
@model SCMS.UI.Models.TenderAnalysis

@{AjaxOptions ajaxOpts = new AjaxOptions
  {
      UpdateTargetId = "popup-page",
      LoadingElementId = "popup-loading",
      HttpMethod = "Post",
      Url = Url.Action("EvaluateTA"),
      OnSuccess = "ReviewComplete('" + string.Format(Resources.RequestReview_String_EvaluationSuccessMsg, Model.EntityTenderAnalysis.RefNumber) + "', '" + Resources.RequestReview_String_EvaluationComplete + "')"
  };}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="partialViewCard" style="max-width: 1000px;">
    <div class="partialViewCardHeader"><h3>@Resources.TenderAnalysis_String_TenderAnalysisEvaluation</h3></div>
    <br />
    <h4 style="text-align: center;">@Model.EntityTenderAnalysis.RefNumber</h4>
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" style="border: 1px solid grey;
        border-collapse: collapse; padding: 5px; font-size: 12px;">
        <tr class="gridheader">
            <th align="center">
                @Resources.Global_String_Date
            </th>
            <th align="center">
                @Resources.Global_String_TenderAnalyaisNo
            </th>
            <th align="center">
                @Resources.Global_String_OrderRequestNo
            </th>
            <th align="center">
                @Resources.Global_String_Currency
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.EntityTenderAnalysis.AnalysisDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.EntityTenderAnalysis.RefNumber
            </td>
            <td align="center">
                @Model.EntityTenderAnalysis.OrderRequest.RefNumber
            </td>
            <td align="center">
                @ViewBag.Currency
            </td>
        </tr>
    </table>
    <table width="98%" align="center" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left">
                @Resources.TenderAnalysis_String_TAIntroductionText
            </td>
        </tr>
    </table>
    @if (Model.HasSuppliers)
    {

        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" style="border: 1px solid grey;
            border-collapse: collapse; padding: 5px; font-size: 12px;">
            <tr class="gridheader">
                <th align="center">
                    @Resources.Global_String_Description
                </th>
                @foreach (var item in Model.SupplierName)
                {
                    <th align="center">
                        @Html.DisplayFor(modelItem => item)
                    </th>
                }
            </tr>
            @{int x = 0; int cols = 1 + Model.SupplierName.Count; string rowClass = ""; }
            @foreach (var item in Model.TBiderQuotes)
            {
                if (x % 2 == 0) { rowClass = "grideven"; }
                if (x % 2 != 0) { rowClass = "gridodd"; }
                if (x >= 0) { x = x + 1; }
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.ItemDescription)
                    </td>
                    @foreach (var subItem in item.UnitCost)
                    { 
                        <td align="right">
                            @subItem.ToString("#,##0.00")
                        </td>
                    }
                </tr>
            }
            @if (Model.TransportCost.Count > 0)
            {
                <tr>
                    <td>
                        @Resources.Global_String_TransportCost
                    </td>
                    @foreach (var item in Model.TransportCost)
                    {
                        <td align="right">
                            @item.ToString("#,##0.00")
                        </td>
                    }
                </tr>
            }
            <tr>
                <td>
                    @Resources.Global_String_TotalCost
                </td>
                @foreach (var item in Model.TotalCost)
                {
                    <td align="right">
                        @item.ToString("#,##0.00")
                    </td>
                }
            </tr>
            <tr class="gridheader">
                <td align="center" colspan=@cols>
                    @Resources.Global_String_TermsAndConditions
                </td>
            </tr>
            @if (Model.ShippingTerm.Count > 0)
            {
                <tr>
                    <td>
                        @Resources.Global_String_ShippingTerms
                    </td>
                    @foreach (var item in Model.ShippingTerm)
                    {
                        <td>@Html.DisplayFor(modelItem => item)
                        </td>
                    }
                </tr>
            }
            @if (Model.DeliveryTime.Count > 0)
            {
                <tr>
                    <td>
                        @Resources.GoodsReceivedNote_LoadGRNVerifyItems_DeliveryDate
                    </td>
                    @foreach (var item in Model.DeliveryTime)
                    {
                        <td>
                            @item.ToString("dd-MMM-yyyy")
                        </td>
                    }
                </tr>
            }
            @if (Model.Warrant.Count > 0)
            {
                <tr>
                    <td>
                        @Resources.TenderAnalysis_String_Warranty
                    </td>
                    @foreach (var item in Model.Warrant)
                    {
                        <td>@Html.DisplayFor(modelItem => item)
                        </td>
                    }
                </tr>
            }
            @if (Model.TermzOfPayment.Count > 0)
            {
                <tr>
                    <td>
                        @Resources.Global_String_PaymentTerms
                    </td>
                    @foreach (var item in Model.TermzOfPayment)
                    {
                        <td>@Html.DisplayFor(modelItem => item)
                        </td>
                    }
                </tr>
            }
            @if (Model.others.Count > 0)
            {
                <tr>
                    <td>
                        @Resources.Global_String_Other
                    </td>
                    @foreach (var item in Model.others)
                    {
                        <td>@Html.DisplayFor(modelItem => item)
                        </td>
                    }
                </tr>
            }
        </table>
    }
    <br />
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        @Html.ValidationSummary(true)
        <table width="98%" align="center" style="border: 1px solid grey; border-collapse: collapse; padding: 5px; font-size: 12px;">
            <tr class="gridheader">
                <td colspan="2">@Resources.TenderAnalysis_String_RecommendSupplier</td>
            </tr>
            <tr>
                <td align="right" width="40%">@Resources.TenderAnalysis_String_SelectSupplier:</td>
                <td width="60%">
                    @Html.DropDownListFor(m => m.RecommendedSupplierId, Model.Suppliers, "--Please Select--")<br />
                    @Html.ValidationMessageFor(m => m.RecommendedSupplierId, "Required")
                </td>
            </tr>
            <tr>
                <td align="right" valign="top">@Resources.Global_String_Remarks:</td>
                <td>
                    @Html.TextAreaFor(m => m.Remarks, new { rows = "2" })
                    @Html.HiddenFor(m => m.EntityTenderAnalysis.Id)
                </td>
            </tr>
        </table>   
        <br />
        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" style="border: 1px solid grey;
            border-collapse: collapse; padding: 5px; font-size: 12px;">
            <tr class="gridheader">
                <th style="width: 30%;">
                @Resources.TenderAnalysis_String_AnalysisPreparedBy
            </th>
            <th style="width: 30%;">
                @Resources.Global_String_Title
            </th>
            <th style="width: 20%;">
                @Resources.Global_String_Date
            </th>
            <th style="width: 20%;">
                @Resources.Global_String_Signature
            </th>
            </tr>
            <tr>
                <td align="center">
                    @Model.EntityTenderAnalysis.Staff1.Person.FirstName &nbsp; @Model.EntityTenderAnalysis.Staff1.Person.OtherNames
                </td>
                <td align="center">
                    @Model.EntityTenderAnalysis.Staff1.Designation.Name
                </td>
                <td align="center">
                    @Model.EntityTenderAnalysis.PreparedOn.Value.ToString("dd/MM/yyyy h:mm tt")
                </td>
                <td align="center">
                    @if (Model.EntityTenderAnalysis.Staff1 != null && Model.EntityTenderAnalysis.Staff1.Person.SignatureImage != null)
                    { 
                        <img src="@Url.Action("Photo", "Person", new { id = Model.EntityTenderAnalysis.Staff1.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                    }
                </td>
            </tr>
            <tr>
                <td colspan="4" align="center">
                    <br />
                    <input type="submit" class="btn tertiary"  value="@Resources.RequestReview_String_Recommend" />
                    &nbsp; &nbsp;
                    <input type="button" class="btn tertiary"  value="  @Resources.Global_String_Reject  " onclick="sendRequest('/RequestReview/RejectTA/@Model.EntityTenderAnalysis.Id', 'popup-page', 'popup-loading'); ReviewComplete('@Resources.RequestReview_String_TARejectedMsg', '@Resources.RequestReview_String_EvaluationComplete');" />
                </td>
            </tr>
        </table>
        }
        <br />
</div>